package com.campus.mapper;

import com.campus.entity.ChatRecords;
import com.campus.vo.ChatRecordsVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author TaiZai
 * @data 2024/11/9 16:01
 */
@Mapper
public interface AIMapper {

    /**
     * 插入聊天记录数据
     * @param chatRecords
     */
    void insert(ChatRecords chatRecords);

    /**
     * 获取某个用户的全部聊天记录
     * @param userId
     * @return
     */
    @Select("select * from chat_records where user_id = #{userId} order by create_time desc")
    List<ChatRecords> selectByUserId(Long userId);

    /**
     * 根据ID获取聊天记录数据
     * @param recordId
     * @return
     */
    @Select("select * from chat_records where id = #{recordId}")
    ChatRecordsVO.item selectById(Long recordId);

    /**
     * 更新聊天记录数据
     * @param records
     */
    void updateById(ChatRecords records);

    /**
     * 删除单个聊天记录
     * @param recordId
     */
    @Delete("delete from chat_records where id = #{recordId}")
    void deleteById(Long recordId);
}
